package au.org.nh.dao.mongo.impl;

import au.org.nh.dao.GetPatientInfoDAO;
import au.org.nh.dao.PatientInfo;

import com.google.gson.Gson;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;

public class GetPatientInfoMongoImpl implements GetPatientInfoDAO {
	DBCollection collection = null;

	@Override
	public void getAll() throws DBException {
		try {
			collection = MongoDBUtil.getCollection("test");
		} catch (final MongoDBException e) {
			e.printStackTrace();
			throw e;
		}

		final DBCursor cur = collection.find();
		while (cur.hasNext()) {
			final String jsonStr = cur.next().toString();
			final Gson gson = new Gson();
			final PatientInfo info = gson.fromJson(jsonStr, PatientInfo.class);
			System.out.println(info);
		}
	}

	@Override
	public void get(final String id) {
		// TODO Auto-generated method stub

	}

}
